{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "31d5cd30-9d5d-4b53-9c59-ac884b78c799",
   "metadata": {},
   "outputs": [],
   "source": [
    "import turtle\n",
    "\n",
    "turtle.pensize(4)\n",
    "turtle.pencolor('red')\n",
    "turtle.forward(100)\n",
    "turtle.right(90)\n",
    "turtle.forward(100)\n",
    "turtle.right(90)\n",
    "turtle.forward(100)\n",
    "turtle.right(90)\n",
    "turtle.forward(100)\n",
    "turtle.mainloop()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "68310a38-a134-4bf6-96c0-18feb842e370",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "444\n",
      "198\n",
      "39483\n",
      "2.6097560975609757\n",
      "2\n",
      "75\n",
      "199580904170858944588683464608694075062943107082809027605498347841561605181074274426665986623764972439807786764739130193391688887305693295698132008415537889753720415793877902074665765736230030622222862498385818118244547668141388643750880896837470534556730014314212951333550122949806119583030226121714710874561\n"
     ]
    }
   ],
   "source": [
    "a = 321\n",
    "b = 123\n",
    "print(a + b)\n",
    "print(a - b)\n",
    "print(a * b)\n",
    "print(a / b)\n",
    "print(a // b)\n",
    "print(a % b)\n",
    "print(a ** b)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "0eab762e-e159-4d92-8f5a-94841963d55e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "a =  4\n",
      "b =  2\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "4 + 2 = 6\n",
      "4 - 2 = 2\n",
      "4 * 2 = 8\n",
      "4 / 2 = 2.000000\n",
      "4 // 2 = 2\n",
      "4 % 2 = 0\n",
      "4 ** 2 = 16\n"
     ]
    }
   ],
   "source": [
    "a = int(input('a = '))\n",
    "b = int(input('b = '))\n",
    "print('%d + %d = %d' % (a, b, a + b))\n",
    "print('%d - %d = %d' % (a, b, a - b))\n",
    "print('%d * %d = %d' % (a, b, a * b))\n",
    "print('%d / %d = %f' % (a, b, a / b))\n",
    "print('%d // %d = %d' % (a, b, a // b))\n",
    "print('%d %% %d = %d' % (a, b, a % b))\n",
    "print('%d ** %d = %d' % (a, b, a ** b))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d57c6413-a54e-482f-8c1b-967351000256",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "<class 'int'>\n",
      "<class 'float'>\n",
      "<class 'complex'>\n",
      "<class 'str'>\n",
      "<class 'bool'>\n"
     ]
    }
   ],
   "source": [
    "a = 100\n",
    "b = 12.345\n",
    "c = 1 + 5j\n",
    "d = 'hello, world'\n",
    "e = True\n",
    "print(type(a))\n",
    "print(type(b))\n",
    "print(type(c))\n",
    "print(type(d))\n",
    "print(type(e))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "3a4c5061-0f5c-4cca-b215-172335640867",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "a =  9.6\n",
      "flag1 =  True\n",
      "flag2 =  False\n",
      "flag3 =  False\n",
      "flag4 =  True\n",
      "flag5 =  False\n",
      "True\n",
      "False\n"
     ]
    }
   ],
   "source": [
    "a = 5\n",
    "b = 10\n",
    "c = 3\n",
    "d = 4\n",
    "e = 5\n",
    "a += b\n",
    "a -= c\n",
    "a *= d\n",
    "a /= e\n",
    "print(\"a = \", a)\n",
    "\n",
    "flag1 = 3 > 2\n",
    "flag2 = 2 < 1\n",
    "flag3 = flag1 and flag2\n",
    "flag4 = flag1 or flag2\n",
    "flag5 = not flag1\n",
    "print(\"flag1 = \", flag1)\n",
    "print(\"flag2 = \", flag2)\n",
    "print(\"flag3 = \", flag3)\n",
    "print(\"flag4 = \", flag4)\n",
    "print(\"flag5 = \", flag5)\n",
    "print(flag1 is True)\n",
    "print(flag2 is not False)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "id": "ec39f603-0d28-48c8-81ee-66a48798b088",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入华氏温度:  36\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "36.0华氏度 = 2.2摄氏度\n"
     ]
    }
   ],
   "source": [
    "f = float(input('请输入华氏温度: '))\n",
    "c = (f - 32) / 1.8\n",
    "print('%.1f华氏度 = %.1f摄氏度' % (f, c))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "id": "15d6c815-a8c1-4383-accf-34540e0c4218",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入圆的半径:  2.2\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "周长: 13.82\n",
      "面积: 15.21\n"
     ]
    }
   ],
   "source": [
    "import math\n",
    "\n",
    "radius = float(input('请输入圆的半径: '))\n",
    "perimeter = 2 * math.pi * radius\n",
    "area = math.pi * radius * radius\n",
    "print('周长: %.2f' % perimeter)\n",
    "print('面积: %.2f' % area)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "id": "4f0da529-8134-44a9-a12d-39c8cb437a8f",
   "metadata": {},
   "outputs": [
    {
     "name": "stdin",
     "output_type": "stream",
     "text": [
      "请输入年份:  2015\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "False\n"
     ]
    }
   ],
   "source": [
    "year = int(input('请输入年份: '))\n",
    "# 如果代码太长写成一行不便于阅读 可以使用\\或()折行\n",
    "is_leap = (year % 4 == 0 and year % 100 != 0 or\n",
    "           year % 400 == 0)\n",
    "print(is_leap)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6d6f1211-9f35-4d0a-a0c8-1bdff963ba67",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.12.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
